<?xml version='1.0'?>
<!--
Selects the jsxid as string from file browser based on parameters keyword and index.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:param name="keyword"/>
  <xsl:param name="index"/>
  <xsl:output method="xml" omit-xml-declaration="yes"/>
  <xsl:template match="/">
    <SEARCHFILELIST_SEARCH_RECORDID_WRAPPER>
      <xsl:variable name="match_list" select="//record[contains(@name,$keyword)]"/>
      <xsl:variable name="match_list_count" select="count($match_list)"/>
      <xsl:choose>
        <xsl:when test="$match_list_count &gt; 0">
          <xsl:if test="$index &lt;= $match_list_count">
            <xsl:for-each select="$match_list">
              <xsl:if test="position() = $index">
                <xsl:value-of select="@jsxid"/>
              </xsl:if>
            </xsl:for-each>
          </xsl:if>
          <xsl:if test="$index &gt; $match_list_count or $index &lt; 1">
            <xsl:text>SEARCHFILELIST_OVERHANG:</xsl:text><xsl:value-of select="$match_list_count"/>
          </xsl:if>
          <xsl:if test="$index = 'NAN'">
            <xsl:text>SEARCHFILELIST_FOR_MENU:</xsl:text><xsl:copy-of select="$match_list"/>
          </xsl:if>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>SEARCHFILELIST_NO_MATCHED</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </SEARCHFILELIST_SEARCH_RECORDID_WRAPPER>
  </xsl:template>
</xsl:stylesheet>